home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1035
/
1035.xpi
/
chrome
/
1clickweather.jar
/
content
/
1clickweather
/
js
/
config
/
mainconfigwindow.js
< prev
next >
Wrap
Text File
|
2009-10-02
|
39KB
|
876 lines
// � 2005 The Weather Channel Interactive, Inc. All Rights Reserved.
var GlobalLocId = null;
var GlobalCountry = null;
var GlobalDisplayName = null;
var GlobalShouldUpdate = null;
function sendConfigUpdate() {
Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService).notifyObservers(null, "configupdate", GlobalLocId);
}
function loadMainWindow() {
// INCLUDE ALL OTHER JS FILES HERE!
try{
jsInclude("chrome://1clickweather/content/js/utils/definitions.js");
jsInclude("chrome://1clickweather/content/js/utils/xul.js");
jsInclude("chrome://1clickweather/content/js/utils/datadumper.js");
jsInclude("chrome://1clickweather/content/js/utils/appconstants.js");
jsInclude("chrome://1clickweather/content/js/utils/configupdateobserver.js");
jsInclude("chrome://1clickweather/content/js/trackingsystem.js");
try{
// fire up the config system.
// loadconfig.js can be included where ever you need access to config variables.
// it will pop GlobalUserConfig and GlobalAppConfig into existance
jsInclude("chrome://1clickweather/content/js/config/loadconfig.js");
}catch(e){
alert("ERROR: " + e);
}
try{
jsInclude("chrome://1clickweather/content/js/data/search.js");
loadSearch();
}catch(e){
alert("error init search: " + e);
}
// create an observer that listens for search changes
try {
var searchObserver = new ConfigUpdateObserver("searchupdate");
searchObserver.setFunction(handleSearchData);
searchObserver.register();
}catch(e) {
alert("ERROR: " + e);
}
// hide the wierd wind speed section in the config
//document.getElementById('wind').setAttribute("hidden", "true");
fixLabels();
// at the beginning make the units dropdown disabled..then the prepop will undo it if needed
document.getElementById("munits_wind").disabled = true;
loadVideoConfig();
checkmacversion();
}catch(e) {
alert("ERROR: " + e);
}
prepopUserData();
try{
if(window.arguments[0].data['setup']){
// where we get here, we know this is the initial setup of the app
// so we need to handle defaults
document.getElementById('user_location').value = '';
GlobalLocId = null;
GlobalCountry = null;
GlobalDisplayName = null;
setupUSDefaults();
}
}catch(e){ }
}
function loadVideoConfig() {
//document.getElementById('video_description_text').childNodes[0].nodeValue = "Turn video forecast on or off. Set your default video preference.";
}
function swapMenuImages(myIndex) {
var i;
for(i=0;i<8;i++) {
if(i == myIndex) {
document.getElementById('menu_img_' + i).src='chrome://1clickweather/skin/icons/confignav/' + i + '_on.png';
} else {
document.getElementById('menu_img_' + i).src='chrome://1clickweather/skin/icons/confignav/' + i + '_off.png';
}
}
}
function fixLabels(){
try{
document.getElementById("config_setup_units_deg1").setAttribute("value", "┬░F, MPH");
document.getElementById("config_setup_units_deg2").setAttribute("value", "┬░C, MPH");
document.getElementById("config_setup_units_deg3").setAttribute("value", "┬░C, present wind speed in ");
// document.getElementById("MainConfigWindow").setAttribute("title", "1-ClickWeather");
}catch(e){ }
}
/*******************************************************************************
* When the save button is hit, we do a saveData()
*******************************************************************************/
function saveData(){
/* tracking */
// doTech.writeLog("saveData method reached");
if(!GlobalLocId && !document.getElementById('user_location').value){
alert("Please enter a Location");
return(false);
}
else if(GlobalLocId){
GlobalShouldUpdate = true; // if the save has kicked off, we should send the update flag
// This is where we do the saving of data
saveUserConfig();
window.close();
if(GlobalUserConfig.getInfo().getIsInitial() == "true"){
var track = new weather_trackingSystem();
track.sendAnalyticusTag(0);
}
return(false);
}
return(false);
}
/* closeWindow() */
function closeWindow(){
// make sure we have a locid and the saveData() function was called
if(GlobalLocId && GlobalShouldUpdate){
sendConfigUpdate();
}
}
/*******************************************************************************
* Search related functions
*******************************************************************************/
function openSearch(){
openXUL("search.xul", 'search', document.getElementById('user_location').value);
}
function clearLocation(){
this.onbluring = true;
// TODO: Change this.
if(!GlobalLocId){
document.getElementById('user_location').value = '';
GlobalLocId = '';
GlobalCountry = '';
GlobalDisplayName = '';
}
}
function changeLocation(){
if(this.onbluring){
var loc = document.getElementById('user_location').value;
if(loc){
var l = GlobalSearch.Search(loc);
if(hashSize(l) != 1){
openXUL("search.xul", 'search', loc);
}else{
for(var i in l){
var d = GlobalSearch.getLocationData(i);
if(d){
parseSearchData(d);
}
}
}
}else{
//alert("no loc");
}
this.onbluring = false;
}
}
// if we got a call to handleSearchData, lets assume it came from the search dialog box.
// that means we just put the data back into the text box
function handleSearchData(subject, topic, data){
if(data){
parseSearchData(data);
document.getElementById('user_location').value = GlobalDisplayName;
}
else
alert("error");
}
function parseSearchData(str){
var selectedUnit=null;
var selectedWindType=null;
if(str){
var locData = str.split('|');
if(locData.length == 3){
GlobalLocId = locData[0];
GlobalCountry = locData[1];
GlobalDisplayName = locData[2];
// show user selection
document.getElementById("user_location").value = GlobalDisplayName;
switch(GlobalCountry){
case 'US':
//setupUSDefaults();
break;
default:
//setupIntlDefaults();
break;
}
// if this is the initial screen, then......
try {
if(window.arguments && window.arguments[0].data['setup']){
if(GlobalCountry == "US") {
selectedUnit = document.getElementById("s");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
document.getElementById("munits_wind").disabled = true;
// enable severe weather
document.getElementById("config_swa_enable").checked = true;
// enable radar
document.getElementById("config_radar_enable").checked = true;
// disable satellite
document.getElementById("config_satellite_enable").checked = false;
// make the video topstory
selectedUnit = document.getElementById("config_video_choices_1073");
document.getElementById("config_video_choices").selectedItem = selectedUnit;
//document.getElementById("config_lifestyle_1").disabled = false;
//document.getElementById("config_lifestyle_2").disabled = false;
//document.getElementById("config_lifestyle_3").disabled = false;
//document.getElementById("config_lifestyle_5").disabled = false;
//document.getElementById("config_lifestyle_6").disabled = false;
//document.getElementById("config_lifestyle_8").disabled = false;
//document.getElementById("config_lifestyle_10").disabled = false;
//document.getElementById("config_lifestyle_12").disabled = false;
}
else if(GlobalCountry == "UK") {
selectedUnit = document.getElementById("uk");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
document.getElementById("munits_wind").disabled = true;
// disable severe weather
document.getElementById("config_swa_enable").checked = false;
// make the video europe
selectedUnit = document.getElementById("config_video_choices_571");
document.getElementById("config_video_choices").selectedItem = selectedUnit;
// disable radar
document.getElementById("config_radar_enable").checked = false;
// enable satellite
document.getElementById("config_satellite_enable").checked = true;
// make the video topstory
selectedUnit = document.getElementById("config_video_choices_1073");
setupIntlDefaults();
}
else{
// now this is what im talking about...we assume that everyone else uses metric units...wow!!!
selectedUnit = document.getElementById("m");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
document.getElementById("munits_wind").disabled = false;
selectedWindType = document.getElementById("km/h");
document.getElementById("munits_wind").selectedItem = selectedWindType;
// disable severe weather
document.getElementById("config_swa_enable").checked = false;
// make the video europe
selectedUnit = document.getElementById("config_video_choices_571");
document.getElementById("config_video_choices").selectedItem = selectedUnit;
// disable radar
document.getElementById("config_radar_enable").checked = false;
// enable satellite
document.getElementById("config_satellite_enable").checked = true;
setupIntlDefaults();
}
} else {
if(GlobalCountry == "US") {
selectedUnit = document.getElementById("s");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
document.getElementById("munits_wind").disabled = true;
document.getElementById("config_satellite_enable").checked = false;
document.getElementById("config_radar_enable").checked = true;
/*document.getElementById("config_lifestyle_1").disabled = false;
document.getElementById("config_lifestyle_2").disabled = false;
document.getElementById("config_lifestyle_3").disabled = false;
document.getElementById("config_lifestyle_5").disabled = false;
document.getElementById("config_lifestyle_6").disabled = false;
document.getElementById("config_lifestyle_8").disabled = false;
document.getElementById("config_lifestyle_10").disabled = false;
document.getElementById("config_lifestyle_12").disabled = false;*/
document.getElementById("config_swa_enable").checked = true;
} else {
if(GlobalCountry =="UK") {
selectedUnit = document.getElementById("uk");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
document.getElementById("munits_wind").disabled = true;
} else {
selectedUnit = document.getElementById("m");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
document.getElementById("munits_wind").disabled = false;
selectedWindType = document.getElementById("km/h");
document.getElementById("munits_wind").selectedItem = selectedWindType;
}
document.getElementById("config_swa_enable").checked = false;
document.getElementById("config_radar_enable").checked = false;
document.getElementById("config_satellite_enable").checked = true;
document.getElementById("config_swa_enable").checked = false;
setupIntlDefaults();
}
}
} catch(e){
}
return(true);
}else{
alert('search parse error: ' + locData.length);
GlobalLocId = '';
GlobalCountry = '';
GlobalDisplayName = '';
}
}
return(false);
}
/*******************************************************************************
* Done with Search related functions
*******************************************************************************/
function prepopUserData() {
var userDefaultProfile = GlobalUserConfig.getAllProfiles().getDefaultProfile();
// start prepop of the setup screen
var userSetupInfo = userDefaultProfile.getSetup();
var userLoc = userSetupInfo.getLocation();
if(userLoc.getLocID() != "" && userLoc.getLocID() != "default" && userLoc.getLocPres() != "" && userLoc.getLocPres() != "default") {
document.getElementById("user_location").value = userLoc.getLocPres();
GlobalLocId = userLoc.getLocID();
GlobalCountry = userLoc.getCountry();
GlobalDisplayName = userLoc.getLocPres();
}
var userUnits = userSetupInfo.getUnits().getName();
if(userUnits == "s" || userUnits == "uk") {
var selectedUnit = document.getElementById(userUnits);
document.getElementById("config_setup_units").selectedItem = selectedUnit;
} else {
// this must be metric then
if(userUnits == "mk") {
document.getElementById("munits_wind").disabled = false;
var selectedWindType = document.getElementById("km/h");
document.getElementById("munits_wind").selectedItem = selectedWindType;
} else if(userUnits == "ms"){
document.getElementById("munits_wind").disabled = false;
selectedWindType = document.getElementById("m/s");
document.getElementById("munits_wind").selectedItem = selectedWindType;
} else {
document.getElementById("munits_wind").disabled = false;
}
selectedUnit = document.getElementById("m");
document.getElementById("config_setup_units").selectedItem = selectedUnit;
}
var userPosition = userSetupInfo.getPosition();
var selectedPosition = document.getElementById(userPosition);
document.getElementById("config_setup_placement").selectedItem = selectedPosition;
// start prepop of the current cond screen
var userCurrentCondInfo = userDefaultProfile.getCurrentCond();
var isCurrentEnabled = userCurrentCondInfo.getIsEnabled();
if(isCurrentEnabled == "true") {
document.getElementById("config_cc_enable").checked = true;
} else {
document.getElementById("config_cc_enable").checked = false;
}
var userSelectedCurrentType = document.getElementById("config_cc_display_" + userCurrentCondInfo.getType());
document.getElementById("config_cc_display").selectedItem = userSelectedCurrentType;
var userSelectedCurrentTooltip = userCurrentCondInfo.getToolTip();
var isCurrentTipEnabled = userSelectedCurrentTooltip.getIsEnabled();
if(isCurrentTipEnabled == "true") {
document.getElementById("config_cc_tooltip_enable").checked = true;
} else {
document.getElementById("config_cc_tooltip_enable").checked = false;
}
var selectedTooltipLocation = document.getElementById("config_cc_tooltip_" + userSelectedCurrentTooltip.getType());
document.getElementById("config_cc_tooltip_display").selectedItem = selectedTooltipLocation;
var userCurrentcondAlerts = userCurrentCondInfo.getAlerts();
var isCurrentAlertsEnabled = userCurrentcondAlerts.getIsEnabled();
if(isCurrentAlertsEnabled == "true") {
document.getElementById("config_swa_enable").checked = true;
} else {
document.getElementById("config_swa_enable").checked = false;
}
var selectedAlertsInterval = document.getElementById("config_swa_interval_" + userCurrentcondAlerts.getInterval());
document.getElementById("config_swa_interval").selectedItem = selectedAlertsInterval;
//start prepop of the todays forecast screen
var userFcst = userDefaultProfile.getForecast();
var userFcstEnabled = userFcst.getIsEnabled();
if(userFcstEnabled == "true") {
document.getElementById("config_fcst_enable").checked = true;
} else {
document.getElementById("config_fcst_enable").checked = false;
}
var userSelectedFcstLocationButton = document.getElementById("config_fcst_display_" + userFcst.getType());
document.getElementById("config_fcst_display").selectedItem = userSelectedFcstLocationButton;
var userFcstTooltip = userFcst.getToolTip();
var isFcstTipEnabled = userFcstTooltip.getIsEnabled();
if(isFcstTipEnabled == "true") {
document.getElementById("config_fcst_tooltip_display").checked = true;
} else {
document.getElementById("config_fcst_tooltip_display").checked = false;
}
var selectedFcstTooltipLocation = document.getElementById("config_fcst_tooltip_display_placement_" + userFcstTooltip.getType());
document.getElementById("config_fcst_tooltip_display_placement").selectedItem = selectedFcstTooltipLocation;
var selectFcstForecastSwitch = document.getElementById("config_fcst_switch_" + userFcst.getForecastSwitch());
document.getElementById("config_fcst_switch").selectedItem = selectFcstForecastSwitch;
//start prepop of the todays extended forecast screen
var userExtFcst = userDefaultProfile.getExtForecast();
var userExtFcstIsEnabled = userExtFcst.getIsEnabled();
if(userExtFcstIsEnabled == "true") {
document.getElementById("config_efcst_enable").checked = true;
} else {
document.getElementById("config_efcst_enable").checked = false;
}
var userSelectedExtFcstLocationButton = document.getElementById("config_efcst_display_" + userExtFcst.getType());
document.getElementById("config_efcst_display").selectedItem = userSelectedExtFcstLocationButton;
var userExtFcstExtended = userExtFcst.getExtDetails();
var userSelectedExtFcstExtendedDays = document.getElementById("config_efcst_days_" + userExtFcstExtended.getDays());
document.getElementById("config_efcst_days").selectedItem = userSelectedExtFcstExtendedDays;
var userSelectedExtFcstDisplayTime = document.getElementById("config_efcst_time_" + userExtFcstExtended.getTime());
document.getElementById("config_efcst_time").selectedItem = userSelectedExtFcstDisplayTime;
var userExtFcstTooltip = userExtFcst.getToolTip();
var isExtFcstTipEnabled = userExtFcstTooltip.getIsEnabled();
if(isExtFcstTipEnabled == "true") {
document.getElementById("config_efcst_tooltip_display").checked = true;
} else {
document.getElementById("config_efcst_tooltip_display").checked = false;
}
var selectedExtFcstTooltipLocation = document.getElementById("config_efcst_tooltip_display_placement_" + userExtFcstTooltip.getType());
document.getElementById("config_efcst_tooltip_display_placement").selectedItem = selectedExtFcstTooltipLocation;
//start prepop of the video screen
var userVideo = userDefaultProfile.getVideo();
var userVideoIsEnabled = userVideo.getIsEnabled();
if(userVideoIsEnabled == "true") {
document.getElementById("config_video_enable").checked = true;
} else {
document.getElementById("config_video_enable").checked = false;
}
var userVideoSelection = document.getElementById("config_video_choices_" + userVideo.getID());
document.getElementById("config_video_choices").selectedItem = userVideoSelection;
//start prepop of the radar screen
var userRadar = userDefaultProfile.getRadar();
var userRadarIsEnabled = userRadar.getIsEnabled();
if(userRadarIsEnabled == "true") {
document.getElementById("config_radar_enable").checked = true;
} else {
document.getElementById("config_radar_enable").checked = false;
}
var userRadarSelection = document.getElementById("config_radar_choices_" + userRadar.getID());
document.getElementById("config_radar_choices").selectedItem = userRadarSelection;
// start prepop of the satellite screen
var userSat = userDefaultProfile.getSatelite();
var userSatIsEnabled = userSat.getIsEnabled();
if(userSatIsEnabled == "true") {
document.getElementById("config_satellite_enable").checked = true;
} else {
document.getElementById("config_satellite_enable").checked = false;
}
var userSatSelection = document.getElementById("config_satellite_choices_" + userSat.getID());
document.getElementById("config_satellite_choices").selectedItem = userSatSelection;
// start prepop of the lifestyle screen
var userLifestyle = userDefaultProfile.getLifeStyle();
var userLifestyleIsEnabled = userLifestyle.getIsEnabled();
if(userLifestyleIsEnabled == "true") {
document.getElementById("config_lifestyle_enable").checked = true;
} else {
document.getElementById("config_lifestyle_enable").checked = false;
}
/*
var allLinks = userLifestyle.getLinks();
for(var nextLinkKey in allLinks) {
document.getElementById("config_lifestyle_" + nextLinkKey).checked = true;
}
*/
/*// check if we need to disable certain links that are only available for US location!!!
if(userLoc.getLocID() != "" && userLoc.getLocID() != "default" && userLoc.getLocPres() != "" && userLoc.getLocPres() != "default") {
if(!(userLoc.getCountry() == "US" || userLoc.getCountry() == "us")) {
document.getElementById("config_lifestyle_1").disabled = true;
document.getElementById("config_lifestyle_2").disabled = true;
document.getElementById("config_lifestyle_3").disabled = true;
document.getElementById("config_lifestyle_5").disabled = true;
document.getElementById("config_lifestyle_6").disabled = true;
document.getElementById("config_lifestyle_8").disabled = true;
document.getElementById("config_lifestyle_10").disabled = true;
document.getElementById("config_lifestyle_12").disabled = true;
}
}*/
}
/************************************************************************
Start hide/show functionality
*************************************************************************/
function hideshowCurrent() {
if(document.getElementById("config_cc_enable").checked != true) {
document.getElementById("cc_hbox_tooltip0").hidden = false;
document.getElementById("cc_hbox_tooltip1").hidden = false;
document.getElementById("cc_hbox_tooltip2").hidden = false;
} else {
document.getElementById("cc_hbox_tooltip0").hidden = true;
document.getElementById("cc_hbox_tooltip1").hidden = true;
document.getElementById("cc_hbox_tooltip2").hidden = true;
}
}
function hideshowCurrentTooltip() {
if(document.getElementById("config_cc_tooltip_enable").checked != true) {
document.getElementById("cc_hbox_tooltip2").hidden = false;
} else {
document.getElementById("cc_hbox_tooltip2").hidden = true;
}
}
function hideshowCurrentAlerts() {
if(document.getElementById("config_swa_enable").checked != true) {
document.getElementById("cc_hbox_alerts1").hidden = false;
} else {
document.getElementById("cc_hbox_alerts1").hidden = true;
}
}
function hideshowLifestyleLinks() {
if(document.getElementById("config_lifestyle_enable").checked != true) {
document.getElementById("config_links_vbox").hidden = false;
} else {
document.getElementById("config_links_vbox").hidden = true;
}
}
function hideshowSatelliteMaps() {
if(document.getElementById("config_satellite_enable").checked != true) {
document.getElementById("config_satellite_choices").hidden = false;
} else {
document.getElementById("config_satellite_choices").hidden = true;
}
}
function showdev(n) {
document.getElementById('setup_pages').selectedIndex=8;
}
function hideshowRadarMaps() {
if(document.getElementById("config_radar_enable").checked != true) {
document.getElementById("config_radar_choices").hidden = false;
} else {
document.getElementById("config_radar_choices").hidden = true;
}
}
function hideshowVideos() {
if(document.getElementById("config_video_enable").checked != true) {
document.getElementById("config_video_choices").hidden = false;
} else {
document.getElementById("config_video_choices").hidden = true;
}
}
function hideshowExtFcst() {
if(document.getElementById("config_efcst_enable").checked != true) {
document.getElementById("extfcst_display_box").hidden = false;
document.getElementById("extfcst_details_box").hidden = false;
document.getElementById("extfcst_tooltip_box").hidden = false;
document.getElementById("extfcst_disaply_check_box").hidden = false;
document.getElementById("extfcst_transition_box").hidden = false;
} else {
document.getElementById("extfcst_display_box").hidden = true;
document.getElementById("extfcst_details_box").hidden = true;
document.getElementById("extfcst_tooltip_box").hidden = true;
document.getElementById("extfcst_disaply_check_box").hidden = true;
document.getElementById("extfcst_transition_box").hidden = true;
}
}
function hideshowExtFcstTooltip() {
if(document.getElementById("config_efcst_tooltip_display").checked != true) {
document.getElementById("extfcst_tooltip_box").hidden = false;
} else {
document.getElementById("extfcst_tooltip_box").hidden = true;
}
}
function hideshowFcst() {
if(document.getElementById("config_fcst_enable").checked != true) {
document.getElementById("fcst_display_box").hidden = false;
document.getElementById("fcst_tooltip_check_box").hidden = false;
document.getElementById("fcst_tooltip_check_box2").hidden = false;
document.getElementById("fcst_transition_label_box").hidden = false;
document.getElementById("fcst_transition_box").hidden = false;
} else {
document.getElementById("fcst_display_box").hidden = true;
document.getElementById("fcst_tooltip_check_box").hidden = true;
document.getElementById("fcst_tooltip_check_box2").hidden = true;
document.getElementById("fcst_transition_label_box").hidden = true;
document.getElementById("fcst_transition_box").hidden = true;
}
}
function hideshowFcstTooltip() {
if(document.getElementById("config_fcst_tooltip_display").checked != true) {
document.getElementById("fcst_tooltip_check_box2").hidden = false;
} else {
document.getElementById("fcst_tooltip_check_box2").hidden = true;
}
}
function setupUSDefaults(){
document.getElementById("config_lifestyle_1").checked = true;
document.getElementById("config_lifestyle_1").disabled = false;
document.getElementById("config_lifestyle_2").checked = true;
document.getElementById("config_lifestyle_2").disabled = false;
document.getElementById("config_lifestyle_3").checked = true;
document.getElementById("config_lifestyle_3").disabled = false;
document.getElementById("config_lifestyle_5").checked = true;
document.getElementById("config_lifestyle_5").disabled = false;
document.getElementById("config_lifestyle_6").checked = true;
document.getElementById("config_lifestyle_6").disabled = false;
document.getElementById("config_lifestyle_8").checked = true;
document.getElementById("config_lifestyle_8").disabled = false;
document.getElementById("config_lifestyle_10").checked = true;
document.getElementById("config_lifestyle_10").disabled = false;
document.getElementById("config_lifestyle_12").checked = true;
document.getElementById("config_lifestyle_12").disabled = false;
//try {
// if(window.arguments[0].data['setup']){
// document.getElementById("config_radar_enable").checked = true;
// document.getElementById("config_satellite_enable").checked = false;
// }
//}catch(e) {
//
//}
}
function setupIntlDefaults() {
document.getElementById("config_lifestyle_1").checked = false;
document.getElementById("config_lifestyle_1").disabled = true;
document.getElementById("config_lifestyle_2").checked = false;
document.getElementById("config_lifestyle_2").disabled = true;
document.getElementById("config_lifestyle_3").checked = false;
document.getElementById("config_lifestyle_3").disabled = true;
document.getElementById("config_lifestyle_5").checked = false;
document.getElementById("config_lifestyle_5").disabled = true;
document.getElementById("config_lifestyle_6").checked = false;
document.getElementById("config_lifestyle_6").disabled = true;
document.getElementById("config_lifestyle_8").checked = false;
document.getElementById("config_lifestyle_8").disabled = true;
document.getElementById("config_lifestyle_10").checked = false;
document.getElementById("config_lifestyle_10").disabled = true;
document.getElementById("config_lifestyle_12").checked = false;
document.getElementById("config_lifestyle_12").disabled = true;
// if initial only
//try {
// if(window.arguments[0].data['setup']){
// document.getElementById("config_radar_enable").checked = false;
// document.getElementById("config_satellite_enable").checked = true;
//document.getElementById("config_radar_choices").hidden = true;
// }
//}catch(e) {
//
//}
}
function saveUserConfig() {
try {
var d = new Date()
var configManager = new ConfigManager();
var userConf = configManager.getUserConfig();
// start saving profile update info
userConf.getInfo().setIsInitial(false);
userConf.getInfo().setLastUpdate(d.getTime());
// start saving of setup window
userConf.getAllProfiles().getDefaultProfile().getSetup().getLocation().setLocID(GlobalLocId);
userConf.getAllProfiles().getDefaultProfile().getSetup().getLocation().setCountry(GlobalCountry);
userConf.getAllProfiles().getDefaultProfile().getSetup().getLocation().setLocPres(GlobalDisplayName);
userConf.getAllProfiles().getDefaultProfile().getSetup().setPosition(document.getElementById("config_setup_placement").value);
var userunits = document.getElementById("config_setup_units").value;
if(userunits == "m") {
userunits = document.getElementById("munits_wind").value;
}
userConf.getAllProfiles().getDefaultProfile().getSetup().getUnits().setName(userunits);
// start saving the current conditions screen
// check if current cond disp is enabled
if(document.getElementById("config_cc_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().setIsEnabled(true);
// set the display type
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().setType(document.getElementById("config_cc_display").value);
// check tooltip
if(document.getElementById("config_cc_tooltip_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getToolTip().setIsEnabled(true);
//set the tooltip type
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getToolTip().setType(document.getElementById("config_cc_tooltip_display").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getToolTip().setIsEnabled(false);
}
} else {
// check display and tooltip to false only..leave the rest alone
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().setIsEnabled(false);
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getToolTip().setIsEnabled(false);
}
//check if alerts are enabled
if(document.getElementById("config_swa_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getAlerts().setIsEnabled(true);
// set interval too!
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getAlerts().setInterval(document.getElementById("config_swa_interval").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getCurrentCond().getAlerts().setIsEnabled(false);
}
// start saving the todays forecast window
if(document.getElementById("config_fcst_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getForecast().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getForecast().setType(document.getElementById("config_fcst_display").value);
if(document.getElementById("config_fcst_tooltip_display").checked) {
userConf.getAllProfiles().getDefaultProfile().getForecast().getToolTip().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getForecast().getToolTip().setType(document.getElementById("config_fcst_tooltip_display_placement").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getForecast().getToolTip().setIsEnabled(false);
}
} else {
// set forecast to false
userConf.getAllProfiles().getDefaultProfile().getForecast().setIsEnabled(false);
// set the forecast tooltip to false
userConf.getAllProfiles().getDefaultProfile().getForecast().getToolTip().setIsEnabled(false);
}
// forecast transition option
userConf.getAllProfiles().getDefaultProfile().getForecast().setForecastSwitch(document.getElementById("config_fcst_switch").value);
// start saving of the ext forecast window
if(document.getElementById("config_efcst_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getExtForecast().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getExtForecast().setType(document.getElementById("config_efcst_display").value);
userConf.getAllProfiles().getDefaultProfile().getExtForecast().getExtDetails().setDays(document.getElementById("config_efcst_days").value);
userConf.getAllProfiles().getDefaultProfile().getExtForecast().getExtDetails().setTime(document.getElementById("config_efcst_time").value);
if(document.getElementById("config_efcst_tooltip_display").checked) {
userConf.getAllProfiles().getDefaultProfile().getExtForecast().getToolTip().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getExtForecast().getToolTip().setType(document.getElementById("config_efcst_tooltip_display_placement").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getExtForecast().getToolTip().setIsEnabled(false);
}
} else {
userConf.getAllProfiles().getDefaultProfile().getExtForecast().setIsEnabled(false);
userConf.getAllProfiles().getDefaultProfile().getExtForecast().getToolTip().setIsEnabled(false);
}
// start saving weather videos
if(document.getElementById("config_video_enable").checked){
userConf.getAllProfiles().getDefaultProfile().getVideo().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getVideo().setID(document.getElementById("config_video_choices").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getVideo().setIsEnabled(false);
}
// start saving weather radar maps
if(document.getElementById("config_radar_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getRadar().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getRadar().setID(document.getElementById("config_radar_choices").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getRadar().setIsEnabled(false);
}
// start saving weather satellite maps
if(document.getElementById("config_satellite_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getSatelite().setIsEnabled(true);
userConf.getAllProfiles().getDefaultProfile().getSatelite().setID(document.getElementById("config_satellite_choices").value);
} else {
userConf.getAllProfiles().getDefaultProfile().getSatelite().setIsEnabled(false);
}
// start saving the links
if(document.getElementById("config_lifestyle_enable").checked) {
userConf.getAllProfiles().getDefaultProfile().getLifeStyle().setIsEnabled(true);
/* var links = {};
var i=1;
for(i=1;i<=12;i++) {
if(document.getElementById("config_lifestyle_" + i).checked) {
links[i] = "true";
}
}
userConf.getAllProfiles().getDefaultProfile().getLifeStyle().setLinks(links);*/
} else {
userConf.getAllProfiles().getDefaultProfile().getLifeStyle().setIsEnabled(false);
}
// at the end..save user config to file
configManager.setUserConfig(userConf);
}catch(e) {
alert("SAVING ERROR: " + e);
}
}
function checkmacversion() {
var isMac = (navigator.userAgent.indexOf('Mac') == -1)?0:1;
if(isMac) {
document.getElementById("MenuBar").hidden = true;
}
}